import * as type from './type'

const mutations = {
    [type.PROINFO](state, action) {
        state.AllInfo = action.payload
        state.swipeImg = action.payload.product.images
        state.proInfo = action.payload.product.product
        let Procode = action.code + '-1'
        state.promotions = action.payload.promotions[Procode]
    },
    [type.COMMENT](state, action) {
        state.commentInfo = action.payload
        state.labels = action.payload.labels

        // 追加合并返回新数组
        let arr = JSON.parse(JSON.stringify(state.commentList))
        arr.push.apply(arr, action.payload.page)
        state.commentList = arr

        state.commentTotal = action.payload.info
    },
    [type.CLEARCOMMENT](state) {
        state.commentList = []
    }
}

export default mutations